package com.tudouji.project.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.system.domain.Businesscode;
import com.tudouji.project.system.service.IBusinesscodeService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 业务编码Controller
 * 
 * @author tudouji
 * @date 2021-10-27
 */
@RestController
@RequestMapping("/system/businesscode")
public class BusinesscodeController extends BaseController
{
    @Autowired
    private IBusinesscodeService businesscodeService;

    /**
     * 查询业务编码列表
     */
    @PreAuthorize("@ss.hasPermi('system:businesscode:list')")
    @GetMapping("/list")
    public TableDataInfo list(Businesscode businesscode)
    {
        startPage();
        List<Businesscode> list = businesscodeService.selectBusinesscodeList(businesscode);
        return getDataTable(list);
    }

    /**
     * 导出业务编码列表
     */
    @PreAuthorize("@ss.hasPermi('system:businesscode:export')")
    @Log(title = "业务编码", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Businesscode businesscode)
    {
        List<Businesscode> list = businesscodeService.selectBusinesscodeList(businesscode);
        ExcelUtil<Businesscode> util = new ExcelUtil<Businesscode>(Businesscode.class);
        return util.exportExcel(list, "businesscode");
    }

    /**
     * 获取业务编码详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:businesscode:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(businesscodeService.selectBusinesscodeById(guid));
    }

    /**
     * 新增业务编码
     */
    @PreAuthorize("@ss.hasPermi('system:businesscode:add')")
    @Log(title = "业务编码", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Businesscode businesscode)
    {
        return toAjax(businesscodeService.insertBusinesscode(businesscode));
    }

    /**
     * 修改业务编码
     */
    @PreAuthorize("@ss.hasPermi('system:businesscode:edit')")
    @Log(title = "业务编码", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Businesscode businesscode)
    {
        return toAjax(businesscodeService.updateBusinesscode(businesscode));
    }

    /**
     * 删除业务编码
     */
    @PreAuthorize("@ss.hasPermi('system:businesscode:remove')")
    @Log(title = "业务编码", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(businesscodeService.deleteBusinesscodeByIds(guids));
    }
}
